//
//  SideDemoCtr.swift
//  soapp_Example
//
//  Created by zhu xietong on 2017/10/12.
//  Copyright © 2017年 CocoaPods. All rights reserved.
//

import Foundation
import soapp
import Eelay
class SideDemoCtr: GesSideController,TableVConfig {
    let tableView = UITableView(frame: [0], style: .plain)
    var sections:TP.section{
        get{
            
            let sec:TP.section = [
                [
                    ["title":"我的收藏"],
                    ["title":"推荐给朋友"],
                    ["title":"离线阅读"],
                    ["title":"设置"],
                    ["title":"关于我们"],
                    ]
            ]
            return sec
        }
    }
    let selector:TP.selector = [
        "<default>":ItemCell.self,
    ]
    
    
    override func viewDidLoad() {
        self.side = .bottom(height: 400.co)
        super.viewDidLoad()
        let line = UIView()
        
        jo_contentView.eelay = [
            [tableView,[ee.T.L.B.R,[30,10,-10,-10]]],
            //            [line,[ee.T.B.R],0.6],
        ]
        
        line.backgroundColor = UIColor.separator_color
        self.configTables(tables: tableView)
        tableView.buildDynamicHeight(height: 200)
        tableView.separatorStyle = .none
        loadingV.loading()
        weak var wself = self
        co_delay(delay: 2) {
            wself?.loadingV.dismiss(animated: true)
            wself?.tableView.load(sections: wself?.sections ?? TP.section(), selector: wself?.selector ?? TP.selector())
            wself?.tableView.backgroundColor = .clear
            wself?.tableView.reloadData()
        }
    }
    
    
    override var backgroundView: UIView{
        let blurView = UIVisualEffectView()
        let sty = UIBlurEffect.Style.extraLight
        let blurEffect = UIBlurEffect(style: sty)
        blurView.effect = blurEffect
//        let blurView = UIView()
//        blurView.backgroundColor = UIColor(shex:"#144393")
        return blurView
    }
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        "功能正在开发中".alert()
        self.close()
    }
    
    func touch(cell: Any, actionID: String, model: NSMutableDictionary) {
        
    }
    deinit {
    }

}

extension SideDemoCtr{
    class ItemCell:JoTableCell{
        let titleL = UILabel()
        override func addLayoutRules() {
            contentView.eelay = [
                [titleL,[ee.T.L.B.R,[10,10,-10,-10]]]
            ]
        }
        override func mo_model_reload() {
            titleL.ui.font16.text(mo.model["title",""])
        }
    }
}




